/*  ----------------------------------------------------------------------------
 *  Arello Mobile
 *  Fast 3d Engine
 *  ----------------------------------------------------------------------------
 * Except where otherwise noted, this work is licensed under
 * http://creativecommons.org/licenses/by/3.0
 */

#ifndef __PICTUREFORMAT_DecompressorPPM_H__
#define __PICTUREFORMAT_DecompressorPPM_H__

#include "Decompressor.h"
#include <NoCopy.h>

namespace liba
{
namespace pictureformat
{

/** @warning only 24-bit (8 bit per channel) PPM are supported. */
class DecompressorPPM : public Decompressor, private Nocopy
{
	int bytes_per_pixel;
	enum { MAX_MIPMAP_LEVEL = 20 };
//	const void * data[MAX_MIPMAP_LEVEL];
	const char * bitmap_data[MAX_MIPMAP_LEVEL];
	int sx[MAX_MIPMAP_LEVEL];
	int sy[MAX_MIPMAP_LEVEL];
	int frame_count;

	const char * current_data;
	Format desired_format;
	int frame;
protected:
	const char * skip_whites( const char * begin, const char * end )const;
public:
	DecompressorPPM(const void * data, int size);
	virtual ~DecompressorPPM();
	virtual int get_width(int frame)const;
	virtual int get_height(int frame)const;
	virtual Format get_best_format()const;
	virtual int get_frame_count()const;
	virtual void reset(Format f, int frame);
	virtual void unpack_scanline(void * dst);
	virtual void skip_scanline(int count);
};

} // namespace pictureformat
} // namespace liba
using namespace liba;

#endif //__PICTUREFORMAT_DecompressorPPM_H__